textiter: fix bug in _gtk_text_btree_get_iter_at_last_toggle()
authorSébastien Wilmet <sebastien.wilmet@uclouvain.be>
Tue, 22 Sep 2015 12:40:57 +0000 (14:40 +0200)
committerSébastien Wilmet <swilmet@gnome.org>
Wed, 7 Oct 2015 14:41:37 +0000 (16:41 +0200)
If the last tag toggle is the end iter, the function returned the wrong
tag toggle.

This resulted in some bugs where the view wasn't relayout/redrawn
correctly.

The function also always returned TRUE, probably because the return
value is used nowhere. But for consistency with
_gtk_text_btree_get_iter_at_first_toggle(), it's better to keep the
return value, and also because otherwise the function would be wrong (it
doesn't always return a tag toggle, if there is none).

https://bugzilla.gnome.org/show_bug.cgi?id=755413

gtk/gtktextiter.c

index c600b832580f9f45c4108ecc8bd62afb8d3eae36..6b31c6485c5a0b8ef5df17fa567200f1aeac36a5 100644 (file)
@@ -5648,14 +5648,21 @@ _gtk_text_btree_get_iter_at_last_toggle  (GtkTextBTree   *tree,
                                           GtkTextIter    *iter,
                                           GtkTextTag     *tag)
 {
+  gboolean found;
+
   g_return_val_if_fail (iter != NULL, FALSE);
   g_return_val_if_fail (tree != NULL, FALSE);
 
   _gtk_text_btree_get_end_iter (tree, iter);
-  gtk_text_iter_backward_to_tag_toggle (iter, tag);
+
+  if (gtk_text_iter_toggles_tag (iter, tag))
+    found = TRUE;
+  else
+    found = gtk_text_iter_backward_to_tag_toggle (iter, tag);
+
   check_invariants (iter);
   
-  return TRUE;
+  return found;
 }
 
 gboolean